package localFiles;

/***
 * @author Ragnvald Fuglestein
 */

import java.io.File;
import java.io.Serializable;
import java.util.List;

import baseStructure.Addon;

public class LocalAlbumAddon extends Addon implements Serializable {
	private static final long serialVersionUID = -5332404216255006473L;

	public static final String ADDON_NAME = "LocalAlbumAddon";
	
	public LocalAlbumAddon(File file) {
		super(ADDON_NAME);
		addFile(file);
	}

	@SuppressWarnings("unchecked")
	public final List<File> getFile() {
		return (List<File>)(List<?>) listField.get("file");
	}
	
	public void addFile(File file) {
		addListField("file", file);
	}
	
	public void removeFile(File file) {
		removeListField("file", file);
	}

	@Override public boolean checkField(Object fieldname) {
		return checkField(fieldname, ANYVALUE);
	}

	@Override public boolean checkField(Object fieldname, Object fieldvalue) {
		if ("file".equals(fieldname)) {
			List<Object> list = listField.get("file");
			
			if (list == null) return false;
			return fieldvalue == ANYVALUE || list.contains(fieldvalue);
		}
		return false;
	}
}
